Examples of Resource Estimation

Try your hand at some of the back-of-the-envelope numbers.

Introduction#

Now that we’ve set the foundation for resource estimation, let’s make use of our background knowledge to estimate resources like servers, storage, and bandwidth. Below, we consider a scenario and a service, make assumptions, and based on those assumptions, we make estimations. Let’s jump right in!

Number of servers required#

Let’s make the following assumptions about a Twitter-like service.

Assumptions:

  • There are 500 million (M) daily active users (DAU).
  • A single user makes 20 requests per day on average.
  • Recall that a single server can handle 8,000 RPS.

Estimating the Number of Servers

Daily active users (DAU)500M
Requests on average / day20
Total requests / dayf10Billion
Total requests / secondf115K
Total servers requiredf15

Indeed, the number above doesn’t seem right. If we only need 15 commodity servers to serve 500M daily users, then why do big services use millions of servers in a data center? The primary reason for this is that the RPS is not enough to estimate the number of servers required to provide a service. Also, we made some underlying assumptions in the calculations above. One of the assumptions was that a request is handled by one server only. In reality, requests go through to web servers that may interact with application servers that may also request data from storage servers. Each server may take a different amount of time to handle each request. Furthermore, each request may be handled differently depending upon the state of the data center, the application, and the request itself. Remember that we have a variety of servers for providing various services within a data center.

Therefore, we approximate the number of servers by depicting how many clients a server handles on a given day:

Number of daily active usersRPS of a server\frac{Number\ of\ daily\ active\ users}{RPS\ of\ a\ server}

In this case, it’s equal to: 500M8000\frac{500 M}{8000} = 62,500.

Note: This may not be an accurate estimation, but it’s a realistic one. Therefore, we use this approach in estimating the number of servers in our design problems. Informally, the equation given above assumes that one server can handle 8,000 users. We use this reference in the rest of the course as well.

Number of servers required for a Twitter-like service

Storage requirements#

In this section, we attempt to understand how storage estimation is done by using Twitter as an example. We estimate the amount of storage space required by Twitter for new tweets in a year. Let’s make the following assumptions to begin with:

  • We have a total of 250 M daily active users.
  • Each user posts three tweets in a day.
  • Ten percent of the tweets contain images, whereas five percent of the tweets contain a video. Any tweet containing a video will not contain an image and vice versa.
  • Assume that an image is 200 KB and a video is 3 MB in size on average.
  • The tweet text and its metadata require a total of 250 Bytes of storage in the database.

Then, the following storage space will be required:

Estimating Storage Requirements

Daily active users (DAU)250M
Daily tweets3
Total requests / dayf750M
Storage required per tweet250 B
Storage required per image200KB
Storage required per video3MB
Storage for tweetsf187.5GB
Storage for imagesf15TB
Storage for videosf112.5TB
Total storagef128TB
  • Total storage required for one day = 0.1875TB+15TB+112.5TB128TB0.1875 TB + 15 TB + 112.5 TB \approx 128 TB
  • Storage required for one year = 365×128TB=46.72PB365 \times 128 TB = 46.72 PB
The total storage required by Twitter in a year

Bandwidth requirements#

In order to estimate the bandwidth requirements for a service, we use the following steps:

  1. Estimate the daily amount of incoming data to the service.
  2. Estimate the daily amount of outgoing data from the service.
  3. Estimate the bandwidth in Gbps (gigabits per second) by dividing the incoming and outgoing data by the number of seconds in a day.

Incoming traffic: Let’s continue from our previous example of Twitter, which requires 128 TBs of storage each day. Therefore, the incoming traffic should support the following bandwidth per second:

128×101286400×812Gbps\frac{128 \times 10^{12}}{86400} \times 8 \approx 12 Gbps

Note: We multiply by 8 in order to convert Bytes into bits because bandwidth is measured in bits per second.

Outgoing traffic: Assume that a single user views 50 tweets in a day. Considering the same ratio of five percent and 10 percent for videos and images, respectively, for the 50 tweets, 2.5 tweets will contain video content whereas five tweets will contain an image. Considering that there are 250 M active daily users, we come to the following estimations:

Estimating Bandwidth Requirements

Daily active users (DAU)250M
Daily tweets viewed50per user
Tweets viewed / secondf145K
Bandwidth required for tweetsf0.3Gbps
Bandwidth required for imagesf23.2Gbps
Bandwidth required for videosf174Gbps
Total bandwidthf197.5Gbps

Twitter will need a total of 12 Gbps12\ Gbps of incoming traffic and 197.5 Gbps197.5\ Gbps of outgoing, assuming that the uploaded content is not compressed. Total bandwidth requirements = 12+197.5=209.5 Gbps12 + 197.5 = 209.5 \ Gbps.

The total bandwidth required by Twitter

Put Back-of-the-envelope Numbers in Perspective
Final Remarks
Mark as Completed
Report an Issue